package com.wonder.app.controller;


import com.wonder.admin.domain.SysAdmin;
import com.wonder.admin.service.SysAdminService;
import com.wonder.app.service.SerialService;
import com.wonder.common.common.AjaxResult;
import com.wonder.framework.authorization.CheckAdminToken;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

@Api(tags = "流水号")
@RestController
@RequestMapping("/app/Serial")
public class SerialController {

    /**
     * 获取流水号
     */
    @Autowired
    private SerialService serialService;

    @Autowired
    private CheckAdminToken checkAdminToken;

    @Autowired
    private SysAdminService adminService;

    @ApiOperation(value = "获取流水号")
    @RequestMapping(value = "/get_serial", method = RequestMethod.POST)
    public AjaxResult<?> getSerial(HttpServletRequest request,@RequestBody Map<String, Object> map) throws Exception {
        String token = checkAdminToken.getTokenFormRequest(request);
        SysAdmin user = adminService.getAdminByToken(token);
        String userName = user.getName();
        Long user_id = user.getUser_id();
        Map<String,Object> data = serialService.getSerial(user_id, map);
        return AjaxResult.success(data);
    }
}
